package com.jason.concurrent.CountDownLatch;

import com.jason.concurrent.callable.ThreadCall;

import java.util.concurrent.CountDownLatch;

/**
 * @Author  yslai
 * @Date  2022/9/19 16:45
 * @Description 创建juc的辅助类 countdownlatch
 */
public class demo1 {


    public static void main(String[] args) {
        CountDownLatch latch = new CountDownLatch(6);

        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                System.out.println("第几个同学走了"+ Thread.currentThread().getName());

                latch.countDown();
                },String.valueOf(i)).start();
        }

        try {
            latch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"走了");

    }
}
